<?php
// header('Content-Type:application/json; charset=utf-8');
// https://source.unsplash.com/random/121x75
// https://pixabay.com/api/?key=20105709-6ec9638d1dc555c8ee20e9b5a&q=yellow+flowers&image_type=photo&w=512&h=340
get_header();
function download_remote_file_with_curl($file_url)
	{
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_POST, 0); 
		curl_setopt($ch,CURLOPT_URL,$file_url); 
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
		$file_content = curl_exec($ch);
		curl_close($ch);
 
		return $file_content;
 
	}

$json=json_decode(download_remote_file_with_curl('https://pixabay.com/api/?key=20105709-6ec9638d1dc555c8ee20e9b5a&q=yellow+flowers&image_type=photo&w=512&h=340'),true);
// var_dump($json['hits'][0]['webformatURL']);
// die();
// die();
// require_once('inc/vendor/autoload.php');
// $pexels = new \Glooby\Pexels\Client("563492ad6f91700001000001c33ef8b4a2c64ee9a635a85590e576c7");
// Unsplash\HttpClient::init([
// 	'applicationId'	=> 'M6pJFtXLk4ttYE8dawrJKYVqT4EqoNsQvfJl2BK0H-E',
// 	'secret'	=> 'TpiS3HD3WP_laj-1Ym-uND1tkIm4VHgVk8NVpygNeYk'

// ]);
// $filters = [
//     'username' => 'andy_brunner',
//     'query'    => 'coffee',
//     'w'        => 512,
//     'h'        => 340
// ];
// $kab=Unsplash\Photo::random($filters);
// $photos=($kab->urls)['custom'];
// var_dump(($kab->urls)['custom']);
// $response = $pexels->search('london');
// $photos = json_decode($pexels->search('scenery')->getBody())->photos;
// var_dump($photos[0]->src->medium);
// var_dump($photo[0]->src->small);
// echo '<img src='.$photos.'>';
// foreach ($photos as $photo) {
//  echo "<img src='{$photo->src->small}' width='{$photo->width}' heigth='{$photo->height}'>";
// }
?>
<style>
	img{
		width: 100%;
		max-width: 100%;
	}
</style>
<?php
get_footer();
